package soccerscope.training;

import robocup.component.geometry.Vektor;

public class PlayerTrainingModel
    extends ObjectTrainingModel {

  // private Player player;

  // training-data for players:
  // 1. body-angle
  private float   body_angle         = 0;

  private float   body_angle_diff    = 0;

  // 2. boolean flags:
  private boolean active             = false;

  private boolean roundView          = false;

  private boolean alignSpeedWithBody = false;

  /**
   * This is a model specialized for players
   * 
   * @param player -
   *          the corresponding player
   */
  public PlayerTrainingModel(
      int id) {

    super(id);
    // this.player = player;
    // this.body_angle = player.angle;
  }

  /**
   * This method checks, if the player should participate in the training
   * lesson. Default is false, so that the players have to be activated first.
   * 
   * @return true, if the player should participate in this training-lesson
   */
  public boolean isActive() {

    return this.active;
  }

  /**
   * This method sets the state of the players participation. true means, the
   * player will participate, false will cancel his participation.
   * 
   * @param active -
   *          the participation state
   */
  public void setActive(boolean active) {

    this.active = active;
  }

  /**
   * This method retrieves the body_angle a player should have. The value
   * reaches from {-180,180].
   * 
   * @return the players body angle
   */
  public float getBody_angle() {

    return this.body_angle;
  }

  /**
   * This method sets the new body angle a player should have. To create values
   * that range from {-180,180], the given angle will be normalized, so that
   * values greater 180 may be set to corresponding negative values, etc.
   * 
   * @param body_angle -
   *          the new body-angle
   */
  public void setBody_angle(float body_angle) {

    this.body_angle = (float) Vektor.normalize(body_angle);
  }

  /**
   * This method retrieves the body angle diffusion, which creates a cone of
   * valid body-angles. The value ranges from [0..180]. The cone is relative to
   * body-angle, where 0 is the body angle and the diffusion will reach to both
   * sides [body_angle - diff, body_angle + diff].
   * 
   * @return the body angles new diffusion
   */
  public float getBody_angle_diff() {

    return this.body_angle_diff;
  }

  /**
   * This method sets the body angles diffusion, which creates a cone of valid
   * body-angles. The value ranges from [0..180]. The cone is relative to
   * body-angle, where 0 is the body angle and the diffusion will reach to both
   * sides [body_angle - diff, body_angle + diff]. A value of 180 makes the body
   * angle totally random, because the cone is opened to a circle!
   * 
   * @param the
   *          new body angle diffusion
   */
  public void setBody_angle_diff(float body_angle_diff) {

    this.body_angle_diff = Math.max(0, body_angle_diff);
    this.body_angle_diff = Math.min(180, body_angle_diff);
  }

  /**
   * This method retrieves the round-view property, which means, that the agent
   * will be turned around so that he may "see" every visible object inside his
   * view-distance to create a more consistent worldmodel.
   * 
   * @return the round-view properties value
   */
  public boolean isRoundView() {

    return this.roundView;
  }

  /**
   * This method sets the round-view property, which means, that the agent will
   * be turned around so that he may "see" every visible object inside his
   * view-distance to create a more consistent worldmodel.
   * 
   * @return the new round-view property
   */
  public void setRoundView(boolean roundView) {

    this.roundView = roundView;
  }

  // public Player getPlayer() {
  // return player;
  // }

  /**
   * This method activates the speed-alignment with body-direction
   * 
   * @param b
   */
  public void setAlignSpeedWithBody(boolean b) {

    this.alignSpeedWithBody = b;
  }

  /**
   * This method activates the speed-alignment with body-direction
   * 
   * @param b
   */
  public boolean getAlignSpeedWithBody() {

    return this.alignSpeedWithBody;
  }
}
